package cn.turboinfo.dongying.api.provider.common.repository.database

import net.sunshow.toolkit.core.qbean.helper.entity.BaseEntity
import nxcloud.foundation.core.data.jpa.constant.JpaConstants
import nxcloud.foundation.core.data.jpa.entity.*
import org.hibernate.annotations.Filter
import org.hibernate.annotations.FilterDef
import java.time.LocalDateTime
import javax.persistence.MappedSuperclass

interface IYCEntity : BaseEntity

@MappedSuperclass
abstract class EmptyYCEntity : JpaEntity(), IYCEntity

@MappedSuperclass
abstract class YCEntity : DefaultJpaEntity(), IYCEntity

@MappedSuperclass
abstract class SoftDeleteYCEntity : SoftDeleteJpaEntity(), DeletedField, IYCEntity

@MappedSuperclass
@FilterDef(
    name = JpaConstants.FILTER_SOFT_DELETE,
    parameters = [],
)
@Filter(name = JpaConstants.FILTER_SOFT_DELETE, condition = "\$FILTER_PLACEHOLDER\$.deleted = 0")
abstract class SoftDeleteWithoutIdYCEntity : JpaEntity(), CreatedTimeField, UpdatedTimeField, DeletedField, IYCEntity {
    override var deleted: Long = 0

    override var createdTime: LocalDateTime = LocalDateTime.now()

    override var updatedTime: LocalDateTime = LocalDateTime.now()
}


@MappedSuperclass
abstract class WithoutIdYCEntity : JpaEntity(), CreatedTimeField, UpdatedTimeField, IYCEntity {

    override var createdTime: LocalDateTime = LocalDateTime.now()

    override var updatedTime: LocalDateTime = LocalDateTime.now()
}
